"""
@author: del
@file: rule_verification.py
@time: 2020/3/111:55
@IDE: PyCharm
"""
import pytest


class RuleVerification(object):
    def __init__(self):
        self.rule = {
            '==': self._eq_status_code,
            "=": self._eq,
            "!=": self._neq,
            ">": self._gt,
            ">=": self._gte,
            "<": self._lt,
            "<=": self._lte,
        }

    @staticmethod
    def _eq_status_code(actual_value, expect_value):
        assert int(actual_value) == int(expect_value), f"验证Status Code，期望值：{expect_value} 与实际值：{actual_value}  不一致! "
        return True

    @staticmethod
    def _eq(actual_value, expect_value):
        pytest.assume(actual_value == expect_value,
                      f'期望值：{str(type(expect_value))[8:-2]}({expect_value})  不等于  实际值：{str(type(actual_value))[8:-2]}({actual_value})  ')

    @staticmethod
    def _neq(actual_value, expect_value):
        pytest.assume(actual_value != expect_value,
                      f'期望值：{str(type(expect_value))[8:-2]} ({expect_value}) 等于 实际值：{str(type(actual_value))[8:-2]}({actual_value})  ')

    @staticmethod
    def _gt(actual_value, expect_value):
        pytest.assume(actual_value > expect_value,
                      f'期望值：{str(type(expect_value))[8:-2]} ({expect_value}) 小于等于 实际值：{str(type(actual_value))[8:-2]}({actual_value})  ')

    @staticmethod
    def _gte(actual_value, expect_value):
        pytest.assume(actual_value >= expect_value,
                      f'期望值：{str(type(expect_value))[8:-2]}({expect_value}) 小于 实际值：{str(type(actual_value))[8:-2]}({actual_value}) ')

    @staticmethod
    def _lt(actual_value, expect_value):
        pytest.assume(actual_value < expect_value,
                      f'期望值：{str(type(expect_value))[8:-2]}({expect_value}) 大于等于 实际值：{str(type(actual_value))[8:-2]}({actual_value}) ')

    @staticmethod
    def _lte(actual_value, expect_value):
        pytest.assume(actual_value <= expect_value,
                      f'期望值：{str(type(expect_value))[8:-2]}({expect_value}) 大于 实际值：{str(type(actual_value))[8:-2]}({actual_value}) ')


if __name__ == '__main__':
    a = RuleVerification()
    # print(a.rule['='](1, 2))
    # print(a.rule['=']("1", "2"))
    # print(a.rule['=']([1, 2], [1, 3]))
    # print(a.rule['=']({1: 2}, {1: 3}))
    # print(a.rule['=']({1, 2}, {1, 4}))
